/**
* Prefix for metric names sent to $wgStatsdServer.
*
- * @see RequestContext::getStats
+ * @see MediaWikiServices::getStatsdDataFactory
* @see BufferingStatsdDataFactory
* @since 1.25
*/
use Config;
use Hooks;
use LBFactory;
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use LoadBalancer;
use MediaWiki\Services\ServiceContainer;
use SiteLookup;
return $this->getService( 'SiteStore' );
}
+ /**
+ * @return StatsdDataFactory
+ */
+ public function getStatsdDataFactory() {
+ return $this->getService( 'StatsdDataFactory' );
+ }
+
///////////////////////////////////////////////////////////////////////////
// NOTE: When adding a service getter here, don't forget to add a test
// case for it in MediaWikiServicesTest::provideGetters() and in
return $services->getConfigFactory()->makeConfig( 'main' );
},
+ 'StatsdDataFactory' => function( MediaWikiServices $services ) {
+ return new BufferingStatsdDataFactory(
+ rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
+ );
+ },
+
///////////////////////////////////////////////////////////////////////////
// NOTE: When adding a service here, don't forget to add a getter function
// in the MediaWikiServices class. The convenience getter should just call
* @author Happy-melon
* @file
*/
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
/**
* The simplest way of implementing IContextSource is to hold a RequestContext as a
/**
* Get the Stats object
*
+ * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+ *
* @since 1.25
- * @return BufferingStatsdDataFactory
+ * @return StatsdDataFactory
*/
public function getStats() {
return $this->getContext()->getStats();
* @author Daniel Friesen
* @file
*/
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
/**
* An IContextSource implementation which will inherit context from another source
*/
private $config;
- /**
- * @var Stats
- */
- private $stats;
-
/**
* @var Timing
*/
/**
* Get the stats object
*
- * @return BufferingStatsdDataFactory
+ * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+ *
+ * @return StatsdDataFactory
*/
public function getStats() {
- if ( !is_null( $this->stats ) ) {
- return $this->stats;
- } else {
- return $this->getContext()->getStats();
- }
+ return MediaWikiServices::getInstance()->getStatsdDataFactory();
}
/**
* @file
*/
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+
/**
* Interface for objects which can provide a MediaWiki context on request
*
/**
* Get the stats object
*
+ * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+ *
* @since 1.25
- * @return BufferingStatsdDataFactory
+ * @return StatsdDataFactory
*/
public function getStats();
* @file
*/
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* Group all the pieces relevant to the context of a request into one instance
*/
private $skin;
- /**
- * @var \Liuggio\StatsdClient\Factory\StatsdDataFactory
- */
- private $stats;
-
/**
* @var Timing
*/
/**
* Get the Stats object
*
- * @return BufferingStatsdDataFactory
+ * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+ *
+ * @return StatsdDataFactory
*/
public function getStats() {
- if ( $this->stats === null ) {
- $prefix = rtrim( $this->getConfig()->get( 'StatsdMetricPrefix' ), '.' );
- $this->stats = new BufferingStatsdDataFactory( $prefix );
- }
- return $this->stats;
+ return MediaWikiServices::getInstance()->getStatsdDataFactory();
}
/**
<?php
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use MediaWiki\MediaWikiServices;
/**
'MainConfig' => [ 'getMainConfig', Config::class ],
'SiteStore' => [ 'getSiteStore', SiteStore::class ],
'SiteLookup' => [ 'getSiteLookup', SiteLookup::class ],
+ 'StatsdDataFactory' => [ 'getStatsdDataFactory', StatsdDataFactory::class ],
];
}
'MainConfig' => [ 'MainConfig', Config::class ],
'SiteStore' => [ 'SiteStore', SiteStore::class ],
'SiteLookup' => [ 'SiteLookup', SiteLookup::class ],
+ 'StatsdDataFactory' => [ 'StatsdDataFactory', StatsdDataFactory::class ],
];
}